/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.inventory.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author sithum
 */
@Entity
@Table(name = "DISCOUNTS", catalog = "", schema = "APP")
@NamedQueries({@NamedQuery(name = "Discounts.findAll", query = "SELECT d FROM Discounts d"), @NamedQuery(name = "Discounts.findByDiscountsId", query = "SELECT d FROM Discounts d WHERE d.discountsId = :discountsId"), @NamedQuery(name = "Discounts.findByItemId", query = "SELECT d FROM Discounts d WHERE d.itemId = :itemId"), @NamedQuery(name = "Discounts.findByPercentage", query = "SELECT d FROM Discounts d WHERE d.percentage = :percentage"), @NamedQuery(name = "Discounts.findByAmount", query = "SELECT d FROM Discounts d WHERE d.amount = :amount"), @NamedQuery(name = "Discounts.findByStartDate", query = "SELECT d FROM Discounts d WHERE d.startDate = :startDate"), @NamedQuery(name = "Discounts.findByEndDate", query = "SELECT d FROM Discounts d WHERE d.endDate = :endDate")})
public class Discounts implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "DISCOUNTS_ID", nullable = false)
    private Integer discountsId;
    @Basic(optional = false)
    @Column(name = "ITEM_ID", nullable = false)
    private int itemId;
    @Column(name = "PERCENTAGE", precision = 8, scale = 2)
    private BigDecimal percentage;
    @Column(name = "AMOUNT", precision = 8, scale = 2)
    private BigDecimal amount;
    @Column(name = "START_DATE")
    @Temporal(TemporalType.DATE)
    private Date startDate;
    @Column(name = "END_DATE")
    @Temporal(TemporalType.DATE)
    private Date endDate;
    @OneToMany(mappedBy = "discountsId", fetch=FetchType.EAGER)
    private List<Item> itemCollection;

    public Discounts() {
    }

    public Discounts(Integer discountsId) {
        this.discountsId = discountsId;
    }

    public Discounts(Integer discountsId, int itemId) {
        this.discountsId = discountsId;
        this.itemId = itemId;
    }

    public Integer getDiscountsId() {
        return discountsId;
    }

    public void setDiscountsId(Integer discountsId) {
        this.discountsId = discountsId;
    }

    public int getItemId() {
        return itemId;
    }

    public void setItemId(int itemId) {
        this.itemId = itemId;
    }

    public BigDecimal getPercentage() {
        return percentage;
    }

    public void setPercentage(BigDecimal percentage) {
        this.percentage = percentage;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public List<Item> getItemCollection() {
        return itemCollection;
    }

    public void setItemCollection(List<Item> itemCollection) {
        this.itemCollection = itemCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (discountsId != null ? discountsId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Discounts)) {
            return false;
        }
        Discounts other = (Discounts) object;
        if ((this.discountsId == null && other.discountsId != null) || (this.discountsId != null && !this.discountsId.equals(other.discountsId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.inventory.entities.Discounts[discountsId=" + discountsId + "]";
    }

}
